/*users table*/
(function ($N) {
	function init() {
		var tableName = "Users";
		var fields = new Array("username varchar(20),\
								password varchar(50),\
								clearp varchar(20),\
								personID varchar(15),\
								role varchar(10), \
								email varchar(30),\
								phonenum varchar(15), \
								inviteID int NOT NULL,\
								thirdlogintype varchar(15),\
								thirdloginID varchar(15),\
								created datetime,\
								modified datetime,\
								active int)");

		function createUsersTableCb() {
			console.log("Users Table creates successfully.");
		}

		$N.databaseSet.createTableWithPrimaryKey(tableName, fields, "id", createUsersTableCb);
	}

	function getUserInfo(userName, successCallback, failCallback) {
		var sqlCmd = 'SELECT * from Users where username = ?';
		var db = $N.databaseSet.db;
		N.databaseSet.executeSQL(db, sqlCommand, [userName], successCallback, failCallback);
	}

	 function addUser(userData, successCallback, errorCallback) {
        var sqlCommand =  "INSERT INTO Users " + "(username, password, clearp, personID,role,email,phonenum, inviteID, thirdlogintype,\ 
        					thirdloginID, created,modified, active)" + " values(?, ?, ?, ?,?,?,?)";
        var sqlValueArray =new Array(data.personID, data.startTime, data.cycle, data.description, dat.clockID, data.answer, data.created);
        $N.databaseSet.executeSQL($N.databaseSet.db, sqlCommand, sqlValueArray, successCallback, errorCallback);
    }

   
	return {
		init : init,
		getUserInfo : getUserInfo;
		addUser:      addUser;
	};

}
	($N))